package com.doubi.controller.api;

import com.doubi.controller.common.BaseController;
import com.doubi.modelvo.sys.AdverVo;
import com.doubi.modelvo.sys.TSysUserVo;
import com.doubi.service.AdverService;
import com.doubi.vo.AppUiModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.List;

@Controller
@RequestMapping("Api/Adver")
@Api(value = "广告模块", tags = "广告模块")
public class ApiAdverController extends BaseController {

    @Autowired
    private AdverService adverService;

    @ApiOperation(value = "获取广告")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "position", value = "位置1. 首页  2.商家中心", required = true, dataType = "int"),
    })
    @GetMapping("List")
    @ResponseBody
    public AppUiModel<List<AdverVo>> list(
            @NotNull(message = "请选择一个位置！") @Min(value = 1, message = "数据不存在！")
            @Max(value = 2, message = "数据不存在！") Integer position) {
        return adverService.getList(position);
    }
}
